package acs;

import java.util.List;

public class Producer implements Runnable{

    List<Producer> list;

    public Producer() {
    }

    public Producer(List<Producer> list) {
        this.list = list;
    }

    @Override
    public void run() {
        if(list.size()>=10){
            System.out.println("库存满了，等待消费者线程");
            try {
                list.wait();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }else{
            list.add(new Producer());
            System.out.println("生产者生产了一个产品");
            list.notifyAll();
        }
    }
}